package com.link.base.base.project.service;

import com.link.base.base.project.dao.mybatis.mapper.CarAnnualSalesMapper;
import com.link.base.base.project.model.CarAnnualSales;
import com.link.core.basic.dao.mapper.BasicMapper;
import com.link.core.basic.service.BasicServiceImpl;
import com.link.core.util.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 年度车型/车企销售额行
 *
 * @author 王昊
 * @date 2021-05-07 10:46:38
 */
@Service
public class CarAnnualSalesServiceImpl extends BasicServiceImpl<CarAnnualSales> implements CarAnnualSalesService {

    @Resource
    private CarAnnualSalesMapper    carAnnualSalesMapper;

    @Override
    public BasicMapper<CarAnnualSales> getBasicMapper() {
        return carAnnualSalesMapper;
    }

    @Override
    public void beforUpsert(CarAnnualSales entity) throws Exception {
        super.beforUpsert(entity);
        //为年份组件拼接为日期格式
        String year = entity.getYear();
        if (StringUtils.isNotBlank(year) && year.length() == 4) {
            entity.setYear(year + "-01-01 00:00:00");
        }
    }
}